// Copyright (c) 2011 Paul lee. All rights reserved
/*---------------------------------
 Project name: calculator
 File name: main.cpp
 SHA1 checksum: n/a
 MD5 checksum: n/a
 Description: console calculator
 Build:	
 Version:
 Release date: Not yet released
 ---------------------------------*/

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int result;

int main (int argc, char * const argv[]) {
	// Check for arguments
	std::cout << "argc: " << argc << "\n";
	for (int i=0; i<argc; i++) {
		printf("argv[%d]: %s",i,argv[i]);
		printf("\n");
	}
	if (argc==1) {
		std::cout << "No arguments\n";
		std::cout << "Syntax error\n-a int1 int2[ int3[ ...]] \n";
		return -1;
	}
	if (strcmp("-a", argv[1])==0 || strcmp("--add", argv[1])==0) {
		std::cout << "Adding...\n";
		for (int i=2; i<argc; i++) {
			result+=atoi(argv[i]);
		}
		std::cout << "Result: " << result << "\n";
	}
	system("read -p 'Press ENTER to contiune...'");
    return result;
}
